package com.it.mytest;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int space;

    public SpacesItemDecoration(int space) {
        this.space = space;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {


        // Add top margin only for the first item to avoid double space between items
        //parent.getChildAdapterPosition(view)!=parent.getAdapter().getItemCount()-1
        if (parent.getChildAdapterPosition(view) != 0 )
            outRect.top = space;
    }
}